Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http2: fix subsequent end calls to not throw #15414

Closed

Conversation

apapirovski
Copy link
Member

Calling Http2ServerResponse.end multiple times should never cause the code to throw an error, subsequent calls should instead return false. This adjusts the behaviour to match http1. Fixes #15385

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

http2, test

@nodejs-github-bot nodejs-github-bot added the http2 Issues or PRs related to the http2 subsystem. label Sep 14, 2017
@jasnell jasnell requested a review from mcollina September 14, 2017 18:00
Calling Http2ServerResponse.end multiple times should never
cause the code to throw an error, subsequent calls should
instead return false. Fix behaviour to match http1.

Fixes: https://github.com/nodejs/node/issues/15385m
@apapirovski apapirovski force-pushed the patch-http2-compat-end-fix branch from 9652050 to 8be7991 Compare September 14, 2017 18:03
@apapirovski
Copy link
Member Author

Forgot to sprinkle a couple of mustCalls in there. Sorry about that.

@apapirovski apapirovski force-pushed the patch-http2-compat-end-fix branch from f2677e5 to 8be7991 Compare September 14, 2017 18:39
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -19,6 +19,9 @@ const {
// but may be invoked repeatedly without throwing errors.
const server = createServer(mustCall((request, response) => {
strictEqual(response.closed, false);
response.on('finish', mustCall(() => process.nextTick(
mustCall(() => doesNotThrow(() => response.end('test', mustNotCall())))
Copy link
Member

@lpinca lpinca Sep 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit (feel free to ignore): mustCall seems redundant here. process.nextTick() callback is always called.

@mcollina
Copy link
Member

@mcollina
Copy link
Member

The failure is not related, landing.

not ok 1683 inspector/test-stop-profile-after-done # TODO : Fix flaky test
Build step 'Jenkins Text Finder' changed build result to UNSTABLE
Sending e-mails to: michael_dawson@ca.ibm.com gib@uk.ibm.com Bethany.Griggs@uk.ibm.com
Notifying upstream projects of job completion
Finished: UNSTABLE

@mcollina
Copy link
Member

Landed as a4e923f.

@mcollina mcollina closed this Sep 18, 2017
mcollina pushed a commit that referenced this pull request Sep 18, 2017
Calling Http2ServerResponse.end multiple times should never
cause the code to throw an error, subsequent calls should
instead return false. Fix behaviour to match http1.

Fixes: #15385
PR-URL: #15414
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
@apapirovski apapirovski deleted the patch-http2-compat-end-fix branch September 19, 2017 14:00
jasnell pushed a commit that referenced this pull request Sep 20, 2017
Calling Http2ServerResponse.end multiple times should never
cause the code to throw an error, subsequent calls should
instead return false. Fix behaviour to match http1.

Fixes: #15385
PR-URL: #15414
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Qard pushed a commit to Qard/ayo that referenced this pull request Sep 21, 2017
Calling Http2ServerResponse.end multiple times should never
cause the code to throw an error, subsequent calls should
instead return false. Fix behaviour to match http1.

Fixes: nodejs/node#15385
PR-URL: nodejs/node#15414
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Qard pushed a commit to Qard/ayo that referenced this pull request Sep 21, 2017
Calling Http2ServerResponse.end multiple times should never
cause the code to throw an error, subsequent calls should
instead return false. Fix behaviour to match http1.

Fixes: nodejs/node#15385
PR-URL: nodejs/node#15414
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
http2 Issues or PRs related to the http2 subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

http2: client browser refresh crashing the server.
6 participants